<!--
 * @Author: YuA
 * @Date: 2021-08-07 20:49:19
 * @LastEditTime: 2021-08-30 10:50:56
 * @FilePath: \backstage\src\components\content\tabControl\TabControl.vue
-->
<template>
  <div class="tabControl" :class="songClass">
    <div class="flex tabControl-title">
      <div
        v-for="(item, index) in title"
        :key="index"
        class="tabCont-item"
        @click="active(index)"
      >
        <span :class="{ color: index == count }" class="iconfont">{{
          item
        }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabControl",
  props: {
    title: {
      type: Array,
      default() {
        return [];
      }
    },
    songClass: {
      type: String,
      default() {
        return "";
      }
    }
  },
  data() {
    return {
      count: 0
    };
  },
  methods: {
    active(index) {
      this.count = index;
      this.$emit("tabClick", index);
    }
  }
};
</script>

<style lang="scss" scoped>
.tabControl {
  min-width: 400px;
  color: #909399;
}
.tabCont-item {
  span {
    padding: 0 5px;
    font-size: 23px;
    transition: all 0.3s linear;
    cursor: pointer;
  }

  &:hover {
    color: #303133;
  }
}
.color {
  color: #303133;
}

.tabControl-title {
  justify-content: center;
}
</style>
